package scanner.impl;

import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import pojo.Customer;
import scanner.DataScanner;

public class DataScannerImpl implements DataScanner
{
	private Scanner scanner;
	private List<Customer> list=new ArrayList<Customer>();
	
	public DataScannerImpl(FileInputStream in) {
		super();
		scanner=new Scanner(in);
	}

	public boolean processLine(String line)
	{
		String[] strs=line.split(" ");
		RegexExpression rx=new RegexExpression();
		if(!rx.RegexFilter(strs[0], strs[1], strs[4], strs[2]))
			return false;
		else
		{
			Customer customer=new Customer(strs[0],strs[1],strs[2],strs[3],strs[4]);
			list.add(customer);
			return true;
		}
	}
	public List<Customer> scann() 
	{
		String line = null;
		while(scanner.hasNext())
		{
			line=scanner.nextLine();
			processLine(line);
		}
		return list;
	}
}
